<template>
	<!-- 正式工\日工信息描述 -->
	<view class="calender-detail">
		<view class="head1">
			<view class="head1-left" @click.stop="preDay">
				前一天
			</view>
			<picker mode="date" :value="date" fields="month" @change="bindDateChange">
				<text class="head1-text">{{ (nowDate.year||'') +'年'+( nowDate.month||'')+'月'}}</text>
			</picker>
			<view class="head1-right" @click.stop="nextDay">
				后一天
			</view>
		</view>
		<view class="head">
			<view class="head-left">
				日工
			</view>
			<view class="head-right">
				320.00
			</view>
		</view>
		<div class="line"></div>
		<view class="calender-content">
			<view class="calender-content-li-title">
				正式工
			</view>
			<view class="calender-content-li calender-content-li1">
				上班：1个工
			</view>
			<view class="calender-content-li  calender-content-li2">
				<text>加班：2.5小时</text>
				<text class="t2">450</text>
			</view>
			<view class="calender-content-item">
				<view class="calender-content-item-top">
					<text>上班时间：2024-02-04 08:26:34</text>
					<view class="tag">
						正常
					</view>
				</view>
				<view class="calender-content-item-info">
					签到IP：
				</view>
				<view class="calender-content-item-info">
					签到地址： 松江厂区 2号楼2号考勤机
				</view>
			</view>
			<view class="calender-content-item">
				<view class="calender-content-item-top">
					<text>下班时间：2024-02-04  08:26:34</text>
					<view class="tag">
						正常
					</view>
				</view>
				<view class="calender-content-item-info">
					签到IP：
				</view>
				<view class="calender-content-item-info">
					签到地址： 松江厂区 2号楼2号考勤机
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Calendar from './components/m-calendar/util.js';
	export default {
		data() {
			return {
				date: '',
				weeks: [],
				calendar: {},
				nowDate: '',
			};
		},
		onLoad(e) {
			if (e.date) {
				this.date = e.date;
				// 获取日历方法实例
				this.cale = new Calendar({
					date: e.date,
					selected: [],
					startDate: '',
					endDate: '',
					range: false,
				})
				this.init(e.date)
			}
		},
		watch: {
			nowDate() {
				this.date = this.nowDate.fullDate
			},
		},
		methods: {
			/**
			 * 初始化日期显示
			 * @param {Object} date
			 */
			init(date) {
				this.cale.setDate(date)
				this.weeks = this.cale.weeks
				this.nowDate = this.calendar = this.cale.getInfo(date)
			},
			// 上一天
			preDay() {
				const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'day').fullDate
				this.setDate(preDate)
			},
			// 下一天
			nextDay() {
				const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'day').fullDate
				this.setDate(nextDate)
				console.log(this.nowDate, "this.nowDate")
			},
			bindDateChange(e) {
				const value = e.detail.value + '-1'
				console.log(this.cale.getDate(value), 23);
				this.init(value)
			},
			/**
			 * 设置日期
			 * @param {Object} date
			 */
			setDate(date) {
				this.cale.setDate(date)
				this.weeks = this.cale.weeks
				this.nowDate = this.cale.getInfo(date)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.calender-detail {
		.head1 {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 34rpx;
			margin-top: 21rpx;

			.head1-left {
				width: 159rpx;
				height: 64rpx;
				background: #FFAE13;
				border-radius: 0rpx 10rpx 10rpx 0rpx;
				font-weight: 500;
				font-size: 30rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 64rpx;
			}

			.head1-text {
				font-weight: bold;
				font-size: 32rpx;
				color: #222222;
			}

			.head1-right {
				width: 162rpx;
				height: 64rpx;
				background: #3A92FF;
				border-radius: 10rpx 0rpx 0rpx 10rpx;
				font-weight: 500;
				font-size: 30rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 64rpx;
			}
		}

		.head {
			font-weight: 500;
			font-size: 30rpx;
			color: #222222;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin: 0 32rpx 57rpx 32rpx;

			.head-left {}

			.head-right {}
		}

		.line {
			width: 100%;
			height: 10rpx;
			background: #F0F0F0;
		}

		.calender-content {
			margin: 0 22rpx;

			.calender-content-li {
				display: flex;
				justify-content: space-between;
				font-weight: 500;
				font-size: 30rpx;
				color: #222222;

				.t2 {
					font-weight: bold;
				}
			}

			.calender-content-li1 {
				margin-bottom: 28rpx;
			}

			.calender-content-li2 {
				margin-bottom: 52rpx;
			}

			.calender-content-li-title {
				font-weight: bold;
				font-size: 32rpx;
				color: #222222;
				margin-top: 39rpx;
				margin-bottom: 37rpx;
			}

			.calender-content-item {
				background: #F5F5FC;
				border-radius: 12rpx;
				margin: 0 auto 20rpx auto;
				padding: 35rpx 21rpx 42rpx 32rpx;

				.calender-content-item-top {
					display: flex;
					align-items: center;

					text {
						font-weight: 500;
						font-size: 30rpx;
						color: #222222;
						margin-right: 34rpx;
					}

					.tag {
						width: 60rpx;
						height: 36rpx;
						font-weight: 500;
						font-size: 22rpx;
						color: #FFFFFF;
						text-align: center;
						line-height: 36rpx;
						background: #3A92FF;
						border-radius: 6rpx;
					}
				}

				.calender-content-item-info {
					font-weight: 500;
					font-size: 30rpx;
					color: #999999;
					margin-top: 31rpx;
				}
			}
		}
	}
</style>